<template>
  <div class="goods" @click="handleClick">
    <img :src="goodsDetail.img" alt="">
    <div>
      <h4>{{goodsDetail.title}}</h4>
      <p>{{goodsDetail.desc}}</p>
    </div>
  </div>
</template>
<script>
import eventbus from '@/utils/eventbus'
export default {
  props: {
    // 如果属性是驼峰命名，在使用组件，给组件这个属性赋值时，需要用连字符隔开
    goodsDetail: {
      type: Object,
      required: true
    }
  },
  methods: {
    handleClick () {
      eventbus.$emit('del', this.goodsDetail.id)
    }
  }
}
</script>
<style scoped>
img {
  width: 70px;
  height: 70px;
  float: left;
}
.goods > div {
  height: 80px;
  background-color: red;
  overflow: hidden;
}
</style>
